package MultiThread;

import java.util.concurrent.*;

public class LikeTea {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService e = Executors.newFixedThreadPool(2);

        FutureTask<String> f1 = new FutureTask<>(new Water());
        FutureTask<String> f2 = new FutureTask<>(new Tea());

        e.submit(f1);
        e.submit(f2);

        System.out.println(f1.get() + ":" + f2.get());
        e.shutdown();
    }


}

class Water implements Callable{

    @Override
    public Object call() throws Exception {
        System.out.println("线程1洗水壶");

        System.out.println("线程1烧水");
        return "水烧好了";
    }
}

class Tea implements Callable{

    @Override
    public Object call() throws Exception {
        System.out.println("线程2洗茶杯");

        System.out.println("线程2准备茶叶");

        return "西湖龙井";
    }
}
